package main.java.ensao.cryptography.elgamalmodule;

import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JTextField;

public class ELGAMALEncryptionListner implements ActionListener {
	
	public void actionPerformed(ActionEvent e) {

		
		JPanel pan = (JPanel) ((JButton) e.getSource()).getParent();
		pan.setForeground(new Color(255, 255, 10));
		
		JTextField p = (JTextField) (((JPanel) pan.getComponent(1))).getComponent(1);
	    JTextField g = (JTextField) (((JPanel) pan.getComponent(2))).getComponent(1);
	    JTextField alpha = (JTextField) (((JPanel) pan.getComponent(7))).getComponent(1);
        JTextField clair = (JTextField) (((JPanel) pan.getComponent(11))).getComponent(1);
    	JTextField k_session = (JTextField) (((JPanel) pan.getComponent(8))).getComponent(1);
	    JTextField chiffré = (JTextField) (((JPanel) pan.getComponent(12))).getComponent(1);
	    JTextField Kalpha = (JTextField) (((JPanel) pan.getComponent(13))).getComponent(1);

	    ElGamal gamal=new ElGamal();
			    
	    gamal.Encryption(clair.getText(),k_session.getText(),p.getText(),g.getText(), alpha.getText());
         
	    chiffré.setText(gamal.getC().toString());
        Kalpha.setText(gamal.getKalpha().toString());
	
		

	}

}
